{layout name="main"/}
<style>
    .modal-backdrop,
    .fade,
    .in {
        display: none;
    }
</style>
<div class="wrapper wrapper-content animated fadeInUp">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox">

                <div class="ibox-title">
                    <h5>会员列表</h5>

                </div>

                <div class="ibox-content">
                    <div class="row m-b-sm m-t-sm">
                        <div class="col-sm-4">
                            <div class="btn-group">
                                <a href="{:url('admin/User/showlist')}" class="btn {if condition=" $user_status==0 "}btn-primary{else}btn-white{/if} btn-sm" type="button">全部</a>
                                <a href="{:url('admin/User/showlist',['user_status'=>1])}" class="btn {if condition=" $user_status==1 "}btn-primary{else}btn-white{/if} btn-sm" type="button">已认证</a>
                                <a href="{:url('admin/User/showlist',['user_status'=>2])}" class="btn {if condition=" $user_status==2 "}btn-primary{else}btn-white{/if} btn-sm" type="button">已冻结</a>

                            </div>

                        </div>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <input type="text" placeholder="搜索(会员编号,会员昵称)" class="input-sm form-control" name=keyword value="{$keyword}"><span class="input-group-btn" style="width:35%">
								<input type="text" placeholder="搜索(注册人)" class="input-sm form-control" name=reg_keyword value="{$reg_keyword}">  </span><span class="input-group-btn">
								<button type="button" class="btn btn-sm btn-primary" onclick="search()">搜索</button> </span>
                            </div>
                        </div>
                    </div>
                    <div class="project-list">
                        <table class="table table-striped table-bordered table-hover dataTables-example dataTable" id="DataTables_Table_0" aria-describedby="DataTables_Table_0_info">
                            <thead>
                                <tr role="row">

                                    <th style="width: 14%;">会员编号/昵称</th>
                                    <th style="width: 14%;">推荐人编号/昵称</th>
                                    <th style="width: 6%;">类型</th>
                                    <th style="width: 7%;">电话</th>
                                    <th style="width: 12%;">注册时间</th>

                                    <th style="width: 8%;">财富币</th>
                                    <th style="width: 5%;">状态</th>
                                    <th>操作</th>
                                </tr>
                            </thead>

                            <!--                            <tbody><tr class="no-records-found"><td colspan="8">没有找到匹配的记录</td></tr></tbody>-->

                            <tbody>
                                {:table_empty_list($list,'暂无数据!',8)} {volist name="list" id="user"}
                                <tr class="gradeA odd">


                                    <td class=" ">{$user->user_uniid}/{$user->user_name}</td>
                                    <td class=" ">{$user->parent_user->user_uniid}/{$user->parent_user->user_name}</td>
                                    <td class="center ">{$user->account_type}</td>
                                    <td class="center ">{$user->phone}</td>
                                    <td class=" ">{$user->create_time}</td>

                                    <td class=" ">{$user->money_cash}</td>



                                    <td class="center"><span class="badge {if condition=" $user->user_status=='已认证'"}badge-primary{/if}">{$user->user_status}</span></td>
                                    <td class="center">
                                        <button class="btn btn-warning btn-xs" data-toggle="modal" data-target="#myModal{$user->user_id}">查看详细</button>
                                        <a href="{:url('admin/User/editUser',['user_id'=>$user->user_id])}" class="btn btn-warning btn-xs">修改信息</a>
                                        <button class="btn btn-warning btn-xs" onclick="show({$user->user_id})"><i class="fa fa-cny"></i> 资金日志</button>
                                        {if condition=" $user->user_status=='已认证'"}
                                        <button class="btn btn-danger btn-xs" onclick="delUser({$user ->user_id})"><i class="fa fa-trash"></i> 冻结用户 </button>
                                        {else}
                                        <button class="btn btn-warning btn-xs" onclick="delUser({$user->user_id})"> 解冻用户 </button>
                                        {/if}
                                        <button class="btn btn-warning btn-xs" onclick="resetpwd({$user->user_id})"> 重设一级密码 </button>
                                        <button class="btn btn-warning btn-xs" onclick="resetpwd2({$user->user_id})"> 重设二级密码 </button>
                                        {if condition="$user->user_type=='user'"}
                                        <button class="btn btn-warning btn-xs" data-toggle="modal" data-target="#opendali{$user->user_id}"> 升级代理 </button>{/if}
                                        {if condition="$user->account_type=='普通会员'"}
                                        <button class="btn btn-warning btn-xs" onclick="update({$user->user_id})"> 升级为理财用户 </button>{/if}

                                    </td>
                                </tr>
                                {/volist}

                            </tbody>

                        </table>


                        <div class="row">
                            <div class="col-sm-6">
                                <div class="dataTables_info" id="DataTables_Table_0_info" role="alert" aria-live="polite" aria-relevant="all">
                                    每页显示 {:getPageSize()} 项，共 {$list->toArray()['total']} 项</div>
                            </div>
                            <div class="col-sm-6">
                                <div class="dataTables_paginate paging_simple_numbers" id="DataTables_Table_0_paginate">
                                    {$list->render()}

                                </div>

                            </div>
                        </div>

                    </div>

                </div>
            </div>
        </div>
    </div>
</div>


<script type="text/javascript" src="/static/js/jquery.citys.js"></script>
{volist name="list" id="vo"}
<div class="modal inmodal fade" id="opendali{$vo->user_id}" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title">升级代理</h4>
            </div>
            <form id="applyAgent{$vo->user_id}">
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">申请会员编号 * </label>
                        <div class="col-sm-5">
                            {$vo->user_uniid}
                        </div>
                        <input type="hidden" name="user_id" value="{$vo->user_id}">
                    </div>

                    <div style="clear:both"></div>


                    <div class="form-group">
                        <label class="col-sm-3 control-label">申请地区 * </label>
                        <div>
                            <div class="input-group m-b citys">
                                <select class="form-control" name="province" style="width:120px"></select>
                                <select class="form-control" name="city" style="width:120px"></select>
                                <select class="form-control" name="area" style="width:120px"></select>
                            </div>
                        </div>
                        <script type="text/javascript">
                            $('.citys').citys({
                                required: false
                            });
                        </script>

                    </div>


                    <div class="form-group">
                        <label class="col-sm-3 control-label">备注</label>
                        <div>

                            <textarea id="ccomment" name="comments" class="form-control" style=" height: 80px;"></textarea>
                        </div>

                    </div>




                    <div class="form-group">
                        <div class="col-sm-offset-3">
                            <button class="btn btn-primary" type="button" onclick="add({$vo->user_id})">提交</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
{/volist} {volist name="list" id="vo"}
<div class="modal inmodal fade" id="myModal{$vo->user_id}" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title">会员信息</h4>
            </div>
            <div class="modal-body">
                <p>
                    推荐人： {$vo->parent_user->user_name|default="/"} {$vo->parent_user->user_uniid} {if $vo->parent_user->phone}({$vo->parent_user->phone}){/if}
                </p>

                <p>
                    会员编号：{$vo->user_uniid}
                </p>
                <p>
                    会员昵称：{$vo->user_name}
                </p>

                <p>
                    银行卡信息：[{$vo->vaild_card->bank_name}] {if $vo->vaild_card->card_sub_bank}[{$vo->vaild_card->card_sub_bank}]{/if} [{$vo->vaild_card->card_name}] [{$vo->vaild_card->card_number}]
                </p>
                <p>
                    身份证号码：{$vo->id_number}
                </p>
                <p>
                    联系电话：{$vo->phone}
                </p>
                <p>
                    注册时间：{$vo->create_time}
                </p>
                <p>
                    当前财富币：{$vo->money_cash}
                </p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>

            </div>
        </div>
    </div>
</div>
{/volist}

<script>
    function add(id) {
        var postdata = $("#applyAgent" + id).serialize();
        post({
            url: "{:url('admin/Agent/setAgent')}",
            data: postdata,
            success: function(res) {
                swal({
                    title: 'success',
                    text: res.message,
                    type: "success"
                }, function() {
                    reload();
                });
            },
            error: function(error) {
                swal("错误", JSON.parse(error.responseText).message, "error");
            }
        });
    }

    function delUser(id) {
        if (confirm("您是否确认冻结/解冻此用户？")) {
            post({
                url: "{:url('admin/User/freeze',[],'')}/user_id/" + id,
                success: function(res) {
                    swal({
                        title: 'success',
                        text: res.message,
                        type: "success"
                    }, function() {
                        reload();
                    });
                },
                error: function(error) {
                    swal("错误", JSON.parse(error.responseText).message, "error");
                }
            });
        }
    }

    function resetpwd(id) {
        if (confirm("您是否确认重置此用户密码？")) {
            post({
                url: "{:url('admin/User/resetpassword',[],'')}/user_id/" + id,
                success: function(res) {
                    swal({
                        title: 'success',
                        text: res.message,
                        type: "success"
                    }, function() {
                        reload();
                    });
                },
                error: function(error) {
                    swal("错误", JSON.parse(error.responseText).message, "error");
                }
            });
        }
    }

    function resetpwd2(id) {
        if (confirm("您是否确认重置此用户密码？")) {
            post({
                url: "{:url('admin/User/resetpassword2',[],'')}/user_id/" + id,
                success: function(res) {
                    swal({
                        title: 'success',
                        text: res.message,
                        type: "success"
                    }, function() {
                        reload();
                    });
                },
                error: function(error) {
                    swal("错误", JSON.parse(error.responseText).message, "error");
                }
            });
        }
    }
    function update(id) {
        if (confirm("您是否确认升级此用户为理财用户？")) {
            post({
                url: "{:url('admin/User/updateuser',[],'')}/user_id/" + id,
                success: function(res) {
                    swal({
                        title: 'success',
                        text: res.message,
                        type: "success"
                    }, function() {
                        reload();
                    });
                },
                error: function(error) {
                    swal("错误", JSON.parse(error.responseText).message, "error");
                }
            });
        }
    }

    function show(id) {
        layer.open({
            type: 2,
            area: ['700px', '530px'],
            fix: false, //不固定
            maxmin: true,
            content: "{:url('admin/User/userMoneyList',[],'')}/user_id/" + id
        });
    }

    function search() {
        var url = "{:url('admin/User/showlist', ['user_status'=>$user_status],'')}";
        var keyword = $("input[name=keyword]").val();
		var reg_keyword = $("input[name=reg_keyword]").val();
        if (keyword != "") {
            url = url + "/keyword/" + keyword;
        }
		if (reg_keyword != "") {
            url = url + "/reg_keyword/" + reg_keyword;
        }
        toUrl(url);
    }
</script>
<script src="/static/js/plugins/layer/layer.min.js"></script>
